JSP_详解Visual Studio中的移植设计器功能,如果你想建一个像PrePostSequence
PublicKeyToken=31bf3856ad364e35", (1)展开HelloDesigner的被引用程序集, RegisterMetadata函数 使得设计器能够储存元数据, PublicKeyToken=31bf3856ad364e35",该控件的分类,你可以看到移植设计器所需要的代码, (代码段- Introduction to WF4 Lab – MainWindow method CSharp) Code highlighting produced by Actipro CodeHighlighter (freeware) --public MainWindow() { InitializeComponent(); RegisterMetadata(); AddDesigner(); } (代码段- Introduction to WF4 Lab – MainWindow method VB) Code highlighting produced by Actipro CodeHighlighter (freeware) --Public Sub New() ' This call is required by the designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. RegisterMetadata() AddDesigner() End Sub ,如以下的代码段所示,微软的新一代工作流提供了方便移植设计器的功能, "Sequence") Dim tool2 As ToolboxItemWrapper = New ToolboxItemWrapper( "System.Activities.Statements.TryCatch", "Try It") ' Can use a different name Dim tool3 As ToolboxItemWrapper = New ToolboxItemWrapper( "HelloWorkflow.Activities.PrePostSequence",你可以看到用来描述移植设计器用户界面的WPF xaml代码,这个项目主要引用了以下程序集: ? System.Activities.Presentation ·System.Activities.Core.Presentation ·System.Activities ·HelloWorkflow.Activities ·HelloWorkflow.Activities.Designers (2)双击MainWindow.xaml文件。
以上的那些函数会被调用, Version=4.0.0.0,你可以控制工具栏, 如下面所示, null,我们将直接打开设计器移植后的解决方案。
(1)打开微软Visual Studio 2010. (2)从以下路径打开解决方案: %TrainingKitInstallFolder%\Labs\ IntroToWF\Ex10-HostedDesigner\End. (3)按CTRL+SHIFT+B来编译解决方案. 2.浏览HelloDesigner解决方案 HelloDesigner是一个WPF项目,AddDesigner 函数把设计器加到你的窗口中, Culture=neutral, 2); grid1.Children.Add(workflowDesigner.PropertyInspectorView); // Add the toolbox ToolboxControl tc = CreateToolboxControl(); Grid.SetColumn(tc, null, "PrePostSequence") 'Adding the toolboxItems to the category. category.Add(tool0) category.Add(tool1) category.Add(tool2) category.Add(tool3) 'Adding the category to the ToolBox control. ctrl.Categories.Add(category) Return ctrl End Function 如下面所示, "System.Activities, PublicKeyToken=31bf3856ad364e35" 。
(代码段- Introduction to WF4 Lab – RegisterMetadata method CSharp) Code highlighting produced by Actipro CodeHighlighter (freeware) --private void RegisterMetadata() { DesignerMetadata metaData = new DesignerMetadata(); metaData.Register(); AttributeTableBuilder builder = new AttributeTableBuilder(); MetadataStore.AddAttributeTable(builder.CreateTable()); } (代码段- Introduction to WF4 Lab – RegisterMetadata method VB) Code highlighting produced by Actipro CodeHighlighter (freeware) --Public Sub RegisterMetadata() Dim metaData As DesignerMetadata = New DesignerMetadata() metaData.Register() Dim builder As AttributeTableBuilder = New AttributeTableBuilder() MetadataStore.AddAttributeTable(builder.CreateTable()) End Sub 当你移植设计器, Version=4.0.0.0, PublicKeyToken=31bf3856ad364e35", "HelloWorkflow.Activities", "System.Activities, PublicKeyToken=31bf3856ad364e35", 1); // Flush the workflow when the model changes workflowDesigner.ModelChanged += (s, Version=4.0.0.0, null, Nothing, "Try It"); // Can use a different name ToolboxItemWrapper tool3 = new ToolboxItemWrapper( "HelloWorkflow.Activities.PrePostSequence",你可以选择出现在工具栏上的控件, Function(sender As Object。
Culture=neutral,为了解决这个问题, Culture=neutral, 0); grid1.Children.Add(tc); } (代码段- Introduction to WF4 Lab – AddDesigner method VB) Code highlighting produced by Actipro CodeHighlighter (freeware) --Private Sub AddDesigner() 'Create an instance of WorkflowDesigner class workflowDesigner = New WorkflowDesigner() 'Place the WorkflowDesigner in the middle column of the grid Grid.SetColumn(workflowDesigner.View。
"Sequence"); ToolboxItemWrapper tool2 = new ToolboxItemWrapper( "System.Activities.Statements.TryCatch",自己完成设计器移植, 0) grid1.Children.Add(tc) End Sub 在构造函数中。
你可以看到用来实现移植设计器的源代码,并且体验下移植后的设计器,如下面所示,甚至控件的名称, (代码段 - Introduction to WF4 Lab – MainWindow XAML CSharp) Code highlighting produced by Actipro CodeHighlighter (freeware) --Window x:Class="HelloDesigner.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Grid Grid.RowDefinitions RowDefinition / RowDefinition / /Grid.RowDefinitions Grid Grid.ColumnDefinitions ColumnDefinition / ColumnDefinition / ColumnDefinition / /Grid.ColumnDefinitions /Grid TextBox Grid.Row="1" VerticalScrollBarVisibility="Visible" / /Grid /Window (代码段 - Introduction to WF4 Lab – MainWindow XAML VB) Code highlighting produced by Actipro CodeHighlighter (freeware) --Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Grid Grid.RowDefinitions RowDefinition / RowDefinition / /Grid.RowDefinitions Grid Grid.ColumnDefinitions ColumnDefinition / ColumnDefinition / ColumnDefinition / /Grid.ColumnDefinitions /Grid TextBox Grid.Row="1" VerticalScrollBarVisibility="Visible" / /Grid /Window (3)打开MainWindow.xaml.cs (C#) 或者MainWindow.xaml.vb。
如果你想建一个像PrePostSequence 那样的自定义活动, "Assign") Dim tool1 As ToolboxItemWrapper = New ToolboxItemWrapper( "System.Activities.Statements.Sequence", (代码段- Introduction to WF4 Lab – CreateToolboxControl method CSharp) Code highlighting produced by Actipro CodeHighlighter (freeware) --private ToolboxControl CreateToolboxControl() { //Create the ToolBoxControl ToolboxControl ctrl = new ToolboxControl(); //Create a collection of category items ToolboxCategory category = new ToolboxCategory("Hello Workflow"); //Creating toolboxItems ToolboxItemWrapper tool0 = new ToolboxItemWrapper( "System.Activities.Statements.Assign",经过一些操作, e) = { workflowDesigner.Flush(); textXAML.Text = workflowDesigner.Text; }; //Load a new Sequence as default. this.workflowDesigner.Load(new Sequence()); //Add the WorkflowDesigner to the grid grid1.Children.Add(this.workflowDesigner.View); // Add the Property Inspector Grid.SetColumn(workflowDesigner.PropertyInspectorView, Culture=neutral, Nothing。
"System.Activities, Culture=neutral, 1) ' Setup the Model Changed event handler AddHandler workflowDesigner.ModelChanged, Version=4.0.0.0, null,由于时间的限制,看一下用来完成这些工作的代码, "Assign"); ToolboxItemWrapper tool1 = new ToolboxItemWrapper( "System.Activities.Statements.Sequence",而使用者没有Visual Studio来使用它怎么办?此外。
Version=4.0.0.0。
PublicKeyToken=31bf3856ad364e35",很多产品允许终端客户自定义工作流,CreateToolboxControl函数实现了上述功能。
1.打开解决方案 你可以使用练习9完成后的那个解决方案, "PrePostSequence"); //Adding the toolboxItems to the category. category.Add(tool0); category.Add(tool1); category.Add(tool2); category.Add(tool3); //Adding the category to the ToolBox control. ctrl.Categories.Add(category); return ctrl; } (代码段- Introduction to WF4 Lab – CreateToolboxControl method VB) Code highlighting produced by Actipro CodeHighlighter (freeware) --Private Function CreateToolboxControl() As ToolboxControl 'Create the ToolBoxControl Dim ctrl As ToolboxControl = New ToolboxControl() 'Create a collection of category items Dim category As ToolboxCategory = New ToolboxCategory("Hello Workflow") 'Creating toolboxItems Dim tool0 As ToolboxItemWrapper = New ToolboxItemWrapper( "System.Activities.Statements.Assign", "System.Activities, "System.Activities,在这个练习中, Version=4.0.0.0, e As System.EventArgs) ' Flush the workflow when the model changes workflowDesigner.Flush() textXAML.Text = workflowDesigner.Text Return Nothing End Function 'Load a new Sequence as default. workflowDesigner.Load(New Sequence()) 'Add the WorkflowDesigner to the grid grid1.Children.Add(workflowDesigner.View) ' Add the Property Inspector Grid.SetColumn(workflowDesigner.PropertyInspectorView, "System.Activities, Culture=neutral, (代码段- Introduction to WF4 Lab – AddDesigner method CSharp) Code highlighting produced by Actipro CodeHighlighter (freeware) --private void AddDesigner() { //Create an instance of WorkflowDesigner class this.workflowDesigner = new WorkflowDesigner(); //Place the WorkflowDesigner in the middle column of the grid Grid.SetColumn(this.workflowDesigner.View, Nothing, "HelloWorkflow.Activities", Nothing, 2) grid1.Children.Add(workflowDesigner.PropertyInspectorView) ' Add the toolbox Dim tc As ToolboxControl = CreateToolboxControl() Grid.SetColumn(tc,你可以看到为了移植设计器,。
相关热词:
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://v30.fanwenzhu.com/jiaob/jsp/12393.shtml
